<template>
  <div class="login">

    <!-- 背景 -->
    <div class="beijing">
      <img src="@/assets/img/login/wxlogo1.png" alt="">
      <img src="@/assets/img/login/wxlogo2.png" alt="">
    </div>
    <!-- 背景 End-->
    <!-- 输入 -->
    <div class="shuru">
      <div class="top">
        <van-form @submit="onSubmit">
          <van-field v-model="username" name="username" label="用户名" placeholder="用户名"
            :rules="[{ required: true, message: '请填写用户名' }]" />
          <van-field v-model="password" type="password" name="password" label="密码" placeholder="密码"
            :rules="[{ required: true, message: '请填写密码' }]" />
          <div style="margin: 16px;">
            <van-button round block type="info" :disabled="!isDeng"  native-type="submit">提交</van-button>
          </div>
        </van-form>

      </div>
      <div class="text">
        <p>未注册的手机号验证后自动为您创建中酒账户</p>
        <p>登录即代表您已经同意中酒网<span>《用户服务协议》</span></p>
      </div>
    </div>
    <!-- 输入 End-->

  </div>
</template>
<script>
export default {
  data() {
    return {
      username: 'hjl',
      password: '123456',
      isDeng: !false,
    }
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
      this.$store.dispatch("loginAsync", {
               name: this.username,
               password: this.password,
           }).then(res => {
               console.log(res);
               if (res.code == 200) {
                   this.$toast("登录成功")
                   let next = this.$route.query.next
                   if (next) {
                       this.$router.push(next)
                   }
                   else {
                       this.$router.push({ name: 'home' })
                   }
                   
               }else{
                   this.$toast(res)
               }
           })
    },
  },
  watch:{
    // password(){
    //   if(this.password=='123456'&&this.username=='hjl'){
    //     this.isDeng=!this.isDeng //TODO
    //   }
     
    // }
  }
}
</script>
<style lang="less">
.login {


  .beijing {
    display: flex;
    justify-content: center;
    height: 160px;
    align-items: center;
    background-color: #f03b3a;

    img {
      margin: 0px 20px;
      width: 137px;
      height: 45px;

    }
  }

  .shuru {
    position: relative;

    z-index: 9999;
    height: 360px;
    background-color: #f6f6f6;

    .top {
      position: absolute;
      left: 10px;
      right: 10px;
      // width: 98%;
      top: -37px;
      height: 250px;
      border-radius: 10px;
      margin: 0 auto;

      border: 1px solid #e5d7d7;

      .van-button{
        background-color: #f03b3a;
        border: none;
      }
    }

    .text {
      position: absolute;
      bottom: 10px;
      left: 20px;
      right: 20px;
      color: #959595;

      p {
        font-size: 12px;
        margin: 10px;

        span {
          color: red;
        }
      }

    }
  }
}
</style>
